<?php
  if( isset($_POST['request_ids']) && isset($_POST['uid']) ) {
    $dbhost = "127.0.0.1";
    $dbname = "test_facebook";
    $dbuser = "root";
    $dbpass = "";

    mysql_connect($dbhost, $dbuser, $dbpass) or die("MySQL Error: " . mysql_error());
    mysql_select_db($dbname) or die("MySQL Error: " . mysql_error());

    $uid = mysql_real_escape_string($_POST['uid']);
    $requests = explode(',',$_POST['request_ids']);
    foreach($requests as $request_id) {
      $request_id = mysql_real_escape_string($request_id);
      mysql_query("INSERT INTO fb_requests (fb_user_id, request_id) VALUES ('$uid', '$request_id')") or die("MySQL Error: " . mysql_error());
    }
  }

  /*
  CREATE TABLE `fb_requests` (
  `fb_user_id` VARCHAR(25) NOT NULL,
  `request_id` VARCHAR(35) NOT NULL,
  `outstanding` tinyint(1) NOT NULL DEFAULT '1',
  UNIQUE KEY `unique_pair` (`fb_user_id`,`request_id`)
  ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  */
?>
                                     